Skip to content

feat: added CACHE_COMPONENT_MS to manage component auth caching#59

Merged
petruki merged 1 commit intomasterfrom
staging
May 6, 2026
Merged

feat: added CACHE_COMPONENT_MS to manage component auth caching#59
petruki merged 1 commit intomasterfrom
staging

Conversation

@petruki
Copy link
Copy Markdown
Member

@petruki petruki commented May 6, 2026

This pull request introduces a new component-level cache with time-to-live (TTL) support to improve performance when validating API tokens, and updates related tests and dependencies. The cache allows for background refreshing of component data and ensures that expired cache entries are refreshed asynchronously, reducing database load and improving response times. The changes also include dependency upgrades and new environment variable configuration.

Component cache implementation and usage:

  • Added a component-level cache to the Cache class in src/helpers/cache/index.js, including methods for enabling, refreshing, and retrieving cached components with TTL enforcement and background refresh logic.
  • Updated appAuth middleware in src/middleware/auth.js to leverage the new component cache for token validation, falling back to the database if needed, and refreshing the cache after validation.
  • Added helper function isTokenValid to encapsulate token validation logic.

Configuration and environment:

  • Introduced the CACHE_COMPONENT_MS environment variable in .env-cmdrc-template to control the TTL for component cache entries.

Testing improvements:

  • Enhanced tests/client-api-cached.test.js to set up the component cache, seed it in test setup, and add comprehensive tests for cache expiry, background refresh, and token renewal scenarios.

Dependency upgrades:

  • Upgraded sinon to version 22, along with related dependencies @sinonjs/fake-timers and diff in package.json and npm-shrinkwrap.json for improved testing support.
  • Updated electron-to-chromium to the latest patch version in npm-shrinkwrap.json.

@petruki petruki added this to the v1.1.0 milestone May 6, 2026
@petruki petruki self-assigned this May 6, 2026
@petruki petruki added the enhancement New feature or request label May 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@petruki petruki merged commit 351ee41 into master May 6, 2026
5 checks passed
@petruki petruki deleted the staging branch May 6, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant